package gui;

import java.util.Observable;

import javax.swing.JComboBox;

/**
 * Control Class.
 * 
 * @author Brian M. Luger
 * @version 11/27/2011
 */
public class CAControl extends Observable {
	
	/*
	 * Panel Manuscript List Combo Box
	 */
	private JComboBox my_manuscript_list
		= new JComboBox();	

	/**
	 * Conference Title (North Panel)
	 */
	private String my_selectedConference;
	
	/**
	 * User Name (North Panel)
	 */
	private String my_selectedUser;
	
	/**
	 * Current Role (North Panel)
	 */
	private String my_selectedRole;
	
	/**
	 * Manuscript Title (South Panel)
	 */
	private String my_manuscriptTitle;
	
	/**
	 * Conference Assistant Control Constructor.
	 */
	public CAControl() {
		setSelectedConference("");
		setSelectedUser("");
		setSelectedRole("");
		setManuscriptTitle("");
	}
	
	/**
	 * Sets the Conference Title and sends updated 
	 * information to the CAPanels.
	 * 
	 * @param the_conf Conference Title
	 */
	public void setSelectedConference(final String the_conf) {
		my_selectedConference = the_conf;
		
		setChanged();
		notifyObservers();
	}
	
	/**
	 * @return Conference Title
	 */
	public String getSelectedConference() {
		return my_selectedConference;
	}
	
	/**
	 * Sets the User field and sends updated information
	 * to the CAPanels.
	 * 
	 * @param the_user The User Name
	 */
	public void setSelectedUser(final String the_user) {
		my_selectedUser = the_user;
		
		setChanged();
		notifyObservers();
	}
	
	/**
	 * @return The Selected Manuscript Title
	 */
	public String getSelectedMan() 
	{
		return my_manuscript_list.getSelectedItem().toString();
	}
	
	/**
	 * @return The User Name
	 */
	public String getSelectedUser() {
		return my_selectedUser;
	}
	
	/**
	 * Sets the Role for the user and sends updated 
	 * information to the CAPanels.
	 * 
	 * @param the_role The current User Role.
	 */
	public void setSelectedRole(final String the_role) {
		my_selectedRole = the_role;
		
		setChanged();
		notifyObservers();
	}
	
	/**
	 * Sets the old manuscript for the submit button 
	 * and send information to the CAPanels.
	 * 
	 * @param the_manuscript_list The Manuscript List.
	 */
	public void setSelectedMan(final JComboBox the_list) 
	{
		my_manuscript_list = the_list;
		
		setChanged();
		notifyObservers();
	}
	
	/**
	 * @return The current Role.
	 */
	public String getSelectedRole() {
		return my_selectedRole;
	}
	
	/**
	 * Sets the title of the Manuscript to be added and 
	 * sends updated information to the CAPanels.
	 * 
	 * @param the_title Title of the Manuscript.
	 */
	public void setManuscriptTitle(final String the_title) {
		my_manuscriptTitle = the_title;
		
		setChanged();
		notifyObservers();
	}
	
	/**
	 * @return The Manuscript Title
	 */
	public String getManuscriptTitle() {
		return my_manuscriptTitle;
	}
	
	/**
	 * Sends updated information to the CAPanels.
	 */
	public void refresh() {
		setChanged();
		notifyObservers();
	}

}
